package leecode

func myPowLCR(x float64, n int) float64 {
	if x == 1 || n == 0 {
		return 1
	}
	flag := -1
	if n >= 0 {
		flag = 1
	} else {
		n = -n
	}
	temp := myPowLCR(x, n/2)
	result := 1.0
	if n%2 == 0 {
		result = temp * temp
	} else {
		result = temp * temp * x
	}
	if flag == -1 {
		result = 1 / result
	}
	return result
}
